package com.example.demo2.dao;

import com.example.demo2.entity.Person;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @author Administrator
 */
public interface PersonRepository extends CrudRepository<Person, Integer> {
    /**
     * 根据id查找用户
     *
     * @param id id
     * @return Person
     */
    @Query("from Person where id=:id")
    Person findOne(@Param(value = "id") Integer id);

    /**
     * 查找所有用户
     *
     * @return Person
     */
    @Query("from Person")
    List<Person> findAllPerson();

}
